//2009/08/20 12:59:49
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class SortMachine
{
public:
    int countMoves(vector <int> a)
    {
		int ret = 0;
		vector<int> b(a);
		for(int i=0; i<a.size(); i++)
		{
			for(int j=i+1; j<b.size(); j++)
			{
				if(a[i] > b[j]) 
				{
					b.push_back(a[i]);
					ret ++;
					break;
				}
			}
		}
		return ret;
    }
};
